<?php


/**
 * Base class that represents a query for the 'person' table.
 *
 * 
 *
 * @method     PersonQuery orderByPersonid($order = Criteria::ASC) Order by the personid column
 * @method     PersonQuery orderBySalutation($order = Criteria::ASC) Order by the salutation column
 * @method     PersonQuery orderByFirstname($order = Criteria::ASC) Order by the firstname column
 * @method     PersonQuery orderByLastname($order = Criteria::ASC) Order by the lastname column
 * @method     PersonQuery orderByEmail($order = Criteria::ASC) Order by the email column
 * @method     PersonQuery orderByBorn($order = Criteria::ASC) Order by the born column
 * @method     PersonQuery orderByPostcode($order = Criteria::ASC) Order by the postcode column
 * @method     PersonQuery orderByStreet($order = Criteria::ASC) Order by the street column
 * @method     PersonQuery orderByLicencenr($order = Criteria::ASC) Order by the licencenr column
 * @method     PersonQuery orderByLicencesince($order = Criteria::ASC) Order by the licencesince column
 *
 * @method     PersonQuery groupByPersonid() Group by the personid column
 * @method     PersonQuery groupBySalutation() Group by the salutation column
 * @method     PersonQuery groupByFirstname() Group by the firstname column
 * @method     PersonQuery groupByLastname() Group by the lastname column
 * @method     PersonQuery groupByEmail() Group by the email column
 * @method     PersonQuery groupByBorn() Group by the born column
 * @method     PersonQuery groupByPostcode() Group by the postcode column
 * @method     PersonQuery groupByStreet() Group by the street column
 * @method     PersonQuery groupByLicencenr() Group by the licencenr column
 * @method     PersonQuery groupByLicencesince() Group by the licencesince column
 *
 * @method     PersonQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method     PersonQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method     PersonQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method     PersonQuery leftJoinCity($relationAlias = null) Adds a LEFT JOIN clause to the query using the City relation
 * @method     PersonQuery rightJoinCity($relationAlias = null) Adds a RIGHT JOIN clause to the query using the City relation
 * @method     PersonQuery innerJoinCity($relationAlias = null) Adds a INNER JOIN clause to the query using the City relation
 *
 * @method     PersonQuery leftJoinCustomer($relationAlias = null) Adds a LEFT JOIN clause to the query using the Customer relation
 * @method     PersonQuery rightJoinCustomer($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Customer relation
 * @method     PersonQuery innerJoinCustomer($relationAlias = null) Adds a INNER JOIN clause to the query using the Customer relation
 *
 * @method     PersonQuery leftJoinLicence($relationAlias = null) Adds a LEFT JOIN clause to the query using the Licence relation
 * @method     PersonQuery rightJoinLicence($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Licence relation
 * @method     PersonQuery innerJoinLicence($relationAlias = null) Adds a INNER JOIN clause to the query using the Licence relation
 *
 * @method     Person findOne(PropelPDO $con = null) Return the first Person matching the query
 * @method     Person findOneOrCreate(PropelPDO $con = null) Return the first Person matching the query, or a new Person object populated from the query conditions when no match is found
 *
 * @method     Person findOneByPersonid(int $personid) Return the first Person filtered by the personid column
 * @method     Person findOneBySalutation(string $salutation) Return the first Person filtered by the salutation column
 * @method     Person findOneByFirstname(string $firstname) Return the first Person filtered by the firstname column
 * @method     Person findOneByLastname(string $lastname) Return the first Person filtered by the lastname column
 * @method     Person findOneByEmail(string $email) Return the first Person filtered by the email column
 * @method     Person findOneByBorn(string $born) Return the first Person filtered by the born column
 * @method     Person findOneByPostcode(int $postcode) Return the first Person filtered by the postcode column
 * @method     Person findOneByStreet(string $street) Return the first Person filtered by the street column
 * @method     Person findOneByLicencenr(int $licencenr) Return the first Person filtered by the licencenr column
 * @method     Person findOneByLicencesince(string $licencesince) Return the first Person filtered by the licencesince column
 *
 * @method     array findByPersonid(int $personid) Return Person objects filtered by the personid column
 * @method     array findBySalutation(string $salutation) Return Person objects filtered by the salutation column
 * @method     array findByFirstname(string $firstname) Return Person objects filtered by the firstname column
 * @method     array findByLastname(string $lastname) Return Person objects filtered by the lastname column
 * @method     array findByEmail(string $email) Return Person objects filtered by the email column
 * @method     array findByBorn(string $born) Return Person objects filtered by the born column
 * @method     array findByPostcode(int $postcode) Return Person objects filtered by the postcode column
 * @method     array findByStreet(string $street) Return Person objects filtered by the street column
 * @method     array findByLicencenr(int $licencenr) Return Person objects filtered by the licencenr column
 * @method     array findByLicencesince(string $licencesince) Return Person objects filtered by the licencesince column
 *
 * @package    propel.generator.ise-php.om
 */
abstract class BasePersonQuery extends ModelCriteria
{
	
	/**
	 * Initializes internal state of BasePersonQuery object.
	 *
	 * @param     string $dbName The dabase name
	 * @param     string $modelName The phpName of a model, e.g. 'Book'
	 * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
	 */
	public function __construct($dbName = 'ise-php', $modelName = 'Person', $modelAlias = null)
	{
		parent::__construct($dbName, $modelName, $modelAlias);
	}

	/**
	 * Returns a new PersonQuery object.
	 *
	 * @param     string $modelAlias The alias of a model in the query
	 * @param     Criteria $criteria Optional Criteria to build the query from
	 *
	 * @return    PersonQuery
	 */
	public static function create($modelAlias = null, $criteria = null)
	{
		if ($criteria instanceof PersonQuery) {
			return $criteria;
		}
		$query = new PersonQuery();
		if (null !== $modelAlias) {
			$query->setModelAlias($modelAlias);
		}
		if ($criteria instanceof Criteria) {
			$query->mergeWith($criteria);
		}
		return $query;
	}

	/**
	 * Find object by primary key.
	 * Propel uses the instance pool to skip the database if the object exists.
	 * Go fast if the query is untouched.
	 *
	 * <code>
	 * $obj  = $c->findPk(12, $con);
	 * </code>
	 *
	 * @param     mixed $key Primary key to use for the query
	 * @param     PropelPDO $con an optional connection object
	 *
	 * @return    Person|array|mixed the result, formatted by the current formatter
	 */
	public function findPk($key, $con = null)
	{
		if ($key === null) {
			return null;
		}
		if ((null !== ($obj = PersonPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
			// the object is alredy in the instance pool
			return $obj;
		}
		if ($con === null) {
			$con = Propel::getConnection(PersonPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}
		$this->basePreSelect($con);
		if ($this->formatter || $this->modelAlias || $this->with || $this->select
		 || $this->selectColumns || $this->asColumns || $this->selectModifiers
		 || $this->map || $this->having || $this->joins) {
			return $this->findPkComplex($key, $con);
		} else {
			return $this->findPkSimple($key, $con);
		}
	}

	/**
	 * Find object by primary key using raw SQL to go fast.
	 * Bypass doSelect() and the object formatter by using generated code.
	 *
	 * @param     mixed $key Primary key to use for the query
	 * @param     PropelPDO $con A connection object
	 *
	 * @return    Person A model object, or null if the key is not found
	 */
	protected function findPkSimple($key, $con)
	{
		$sql = 'SELECT `PERSONID`, `SALUTATION`, `FIRSTNAME`, `LASTNAME`, `EMAIL`, `BORN`, `POSTCODE`, `STREET`, `LICENCENR`, `LICENCESINCE` FROM `person` WHERE `PERSONID` = :p0';
		try {
			$stmt = $con->prepare($sql);			
			$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
			$stmt->execute();
		} catch (Exception $e) {
			Propel::log($e->getMessage(), Propel::LOG_ERR);
			throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
		}
		$obj = null;
		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$obj = new Person();
			$obj->hydrate($row);
			PersonPeer::addInstanceToPool($obj, (string) $key);
		}
		$stmt->closeCursor();

		return $obj;
	}

	/**
	 * Find object by primary key.
	 *
	 * @param     mixed $key Primary key to use for the query
	 * @param     PropelPDO $con A connection object
	 *
	 * @return    Person|array|mixed the result, formatted by the current formatter
	 */
	protected function findPkComplex($key, $con)
	{
		// As the query uses a PK condition, no limit(1) is necessary.
		$criteria = $this->isKeepQuery() ? clone $this : $this;
		$stmt = $criteria
			->filterByPrimaryKey($key)
			->doSelect($con);
		return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
	}

	/**
	 * Find objects by primary key
	 * <code>
	 * $objs = $c->findPks(array(12, 56, 832), $con);
	 * </code>
	 * @param     array $keys Primary keys to use for the query
	 * @param     PropelPDO $con an optional connection object
	 *
	 * @return    PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
	 */
	public function findPks($keys, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
		}
		$this->basePreSelect($con);
		$criteria = $this->isKeepQuery() ? clone $this : $this;
		$stmt = $criteria
			->filterByPrimaryKeys($keys)
			->doSelect($con);
		return $criteria->getFormatter()->init($criteria)->format($stmt);
	}

	/**
	 * Filter the query by primary key
	 *
	 * @param     mixed $key Primary key to use for the query
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function filterByPrimaryKey($key)
	{
		return $this->addUsingAlias(PersonPeer::PERSONID, $key, Criteria::EQUAL);
	}

	/**
	 * Filter the query by a list of primary keys
	 *
	 * @param     array $keys The list of primary key to use for the query
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function filterByPrimaryKeys($keys)
	{
		return $this->addUsingAlias(PersonPeer::PERSONID, $keys, Criteria::IN);
	}

	/**
	 * Filter the query on the personid column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByPersonid(1234); // WHERE personid = 1234
	 * $query->filterByPersonid(array(12, 34)); // WHERE personid IN (12, 34)
	 * $query->filterByPersonid(array('min' => 12)); // WHERE personid > 12
	 * </code>
	 *
	 * @param     mixed $personid The value to use as filter.
	 *              Use scalar values for equality.
	 *              Use array values for in_array() equivalent.
	 *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function filterByPersonid($personid = null, $comparison = null)
	{
		if (is_array($personid) && null === $comparison) {
			$comparison = Criteria::IN;
		}
		return $this->addUsingAlias(PersonPeer::PERSONID, $personid, $comparison);
	}

	/**
	 * Filter the query on the salutation column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterBySalutation('fooValue');   // WHERE salutation = 'fooValue'
	 * $query->filterBySalutation('%fooValue%'); // WHERE salutation LIKE '%fooValue%'
	 * </code>
	 *
	 * @param     string $salutation The value to use as filter.
	 *              Accepts wildcards (* and % trigger a LIKE)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function filterBySalutation($salutation = null, $comparison = null)
	{
		if (null === $comparison) {
			if (is_array($salutation)) {
				$comparison = Criteria::IN;
			} elseif (preg_match('/[\%\*]/', $salutation)) {
				$salutation = str_replace('*', '%', $salutation);
				$comparison = Criteria::LIKE;
			}
		}
		return $this->addUsingAlias(PersonPeer::SALUTATION, $salutation, $comparison);
	}

	/**
	 * Filter the query on the firstname column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByFirstname('fooValue');   // WHERE firstname = 'fooValue'
	 * $query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%'
	 * </code>
	 *
	 * @param     string $firstname The value to use as filter.
	 *              Accepts wildcards (* and % trigger a LIKE)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function filterByFirstname($firstname = null, $comparison = null)
	{
		if (null === $comparison) {
			if (is_array($firstname)) {
				$comparison = Criteria::IN;
			} elseif (preg_match('/[\%\*]/', $firstname)) {
				$firstname = str_replace('*', '%', $firstname);
				$comparison = Criteria::LIKE;
			}
		}
		return $this->addUsingAlias(PersonPeer::FIRSTNAME, $firstname, $comparison);
	}

	/**
	 * Filter the query on the lastname column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByLastname('fooValue');   // WHERE lastname = 'fooValue'
	 * $query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%'
	 * </code>
	 *
	 * @param     string $lastname The value to use as filter.
	 *              Accepts wildcards (* and % trigger a LIKE)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function filterByLastname($lastname = null, $comparison = null)
	{
		if (null === $comparison) {
			if (is_array($lastname)) {
				$comparison = Criteria::IN;
			} elseif (preg_match('/[\%\*]/', $lastname)) {
				$lastname = str_replace('*', '%', $lastname);
				$comparison = Criteria::LIKE;
			}
		}
		return $this->addUsingAlias(PersonPeer::LASTNAME, $lastname, $comparison);
	}

	/**
	 * Filter the query on the email column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByEmail('fooValue');   // WHERE email = 'fooValue'
	 * $query->filterByEmail('%fooValue%'); // WHERE email LIKE '%fooValue%'
	 * </code>
	 *
	 * @param     string $email The value to use as filter.
	 *              Accepts wildcards (* and % trigger a LIKE)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function filterByEmail($email = null, $comparison = null)
	{
		if (null === $comparison) {
			if (is_array($email)) {
				$comparison = Criteria::IN;
			} elseif (preg_match('/[\%\*]/', $email)) {
				$email = str_replace('*', '%', $email);
				$comparison = Criteria::LIKE;
			}
		}
		return $this->addUsingAlias(PersonPeer::EMAIL, $email, $comparison);
	}

	/**
	 * Filter the query on the born column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByBorn('2011-03-14'); // WHERE born = '2011-03-14'
	 * $query->filterByBorn('now'); // WHERE born = '2011-03-14'
	 * $query->filterByBorn(array('max' => 'yesterday')); // WHERE born > '2011-03-13'
	 * </code>
	 *
	 * @param     mixed $born The value to use as filter.
	 *              Values can be integers (unix timestamps), DateTime objects, or strings.
	 *              Empty strings are treated as NULL.
	 *              Use scalar values for equality.
	 *              Use array values for in_array() equivalent.
	 *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function filterByBorn($born = null, $comparison = null)
	{
		if (is_array($born)) {
			$useMinMax = false;
			if (isset($born['min'])) {
				$this->addUsingAlias(PersonPeer::BORN, $born['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($born['max'])) {
				$this->addUsingAlias(PersonPeer::BORN, $born['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(PersonPeer::BORN, $born, $comparison);
	}

	/**
	 * Filter the query on the postcode column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByPostcode(1234); // WHERE postcode = 1234
	 * $query->filterByPostcode(array(12, 34)); // WHERE postcode IN (12, 34)
	 * $query->filterByPostcode(array('min' => 12)); // WHERE postcode > 12
	 * </code>
	 *
	 * @see       filterByCity()
	 *
	 * @param     mixed $postcode The value to use as filter.
	 *              Use scalar values for equality.
	 *              Use array values for in_array() equivalent.
	 *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function filterByPostcode($postcode = null, $comparison = null)
	{
		if (is_array($postcode)) {
			$useMinMax = false;
			if (isset($postcode['min'])) {
				$this->addUsingAlias(PersonPeer::POSTCODE, $postcode['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($postcode['max'])) {
				$this->addUsingAlias(PersonPeer::POSTCODE, $postcode['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(PersonPeer::POSTCODE, $postcode, $comparison);
	}

	/**
	 * Filter the query on the street column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByStreet('fooValue');   // WHERE street = 'fooValue'
	 * $query->filterByStreet('%fooValue%'); // WHERE street LIKE '%fooValue%'
	 * </code>
	 *
	 * @param     string $street The value to use as filter.
	 *              Accepts wildcards (* and % trigger a LIKE)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function filterByStreet($street = null, $comparison = null)
	{
		if (null === $comparison) {
			if (is_array($street)) {
				$comparison = Criteria::IN;
			} elseif (preg_match('/[\%\*]/', $street)) {
				$street = str_replace('*', '%', $street);
				$comparison = Criteria::LIKE;
			}
		}
		return $this->addUsingAlias(PersonPeer::STREET, $street, $comparison);
	}

	/**
	 * Filter the query on the licencenr column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByLicencenr(1234); // WHERE licencenr = 1234
	 * $query->filterByLicencenr(array(12, 34)); // WHERE licencenr IN (12, 34)
	 * $query->filterByLicencenr(array('min' => 12)); // WHERE licencenr > 12
	 * </code>
	 *
	 * @param     mixed $licencenr The value to use as filter.
	 *              Use scalar values for equality.
	 *              Use array values for in_array() equivalent.
	 *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function filterByLicencenr($licencenr = null, $comparison = null)
	{
		if (is_array($licencenr)) {
			$useMinMax = false;
			if (isset($licencenr['min'])) {
				$this->addUsingAlias(PersonPeer::LICENCENR, $licencenr['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($licencenr['max'])) {
				$this->addUsingAlias(PersonPeer::LICENCENR, $licencenr['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(PersonPeer::LICENCENR, $licencenr, $comparison);
	}

	/**
	 * Filter the query on the licencesince column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByLicencesince('2011-03-14'); // WHERE licencesince = '2011-03-14'
	 * $query->filterByLicencesince('now'); // WHERE licencesince = '2011-03-14'
	 * $query->filterByLicencesince(array('max' => 'yesterday')); // WHERE licencesince > '2011-03-13'
	 * </code>
	 *
	 * @param     mixed $licencesince The value to use as filter.
	 *              Values can be integers (unix timestamps), DateTime objects, or strings.
	 *              Empty strings are treated as NULL.
	 *              Use scalar values for equality.
	 *              Use array values for in_array() equivalent.
	 *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function filterByLicencesince($licencesince = null, $comparison = null)
	{
		if (is_array($licencesince)) {
			$useMinMax = false;
			if (isset($licencesince['min'])) {
				$this->addUsingAlias(PersonPeer::LICENCESINCE, $licencesince['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($licencesince['max'])) {
				$this->addUsingAlias(PersonPeer::LICENCESINCE, $licencesince['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(PersonPeer::LICENCESINCE, $licencesince, $comparison);
	}

	/**
	 * Filter the query by a related City object
	 *
	 * @param     City|PropelCollection $city The related object(s) to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function filterByCity($city, $comparison = null)
	{
		if ($city instanceof City) {
			return $this
				->addUsingAlias(PersonPeer::POSTCODE, $city->getPostcode(), $comparison);
		} elseif ($city instanceof PropelCollection) {
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
			return $this
				->addUsingAlias(PersonPeer::POSTCODE, $city->toKeyValue('PrimaryKey', 'Postcode'), $comparison);
		} else {
			throw new PropelException('filterByCity() only accepts arguments of type City or PropelCollection');
		}
	}

	/**
	 * Adds a JOIN clause to the query using the City relation
	 *
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function joinCity($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('City');

		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}

		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'City');
		}

		return $this;
	}

	/**
	 * Use the City relation City object
	 *
	 * @see       useQuery()
	 *
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    CityQuery A secondary query class using the current class as primary query
	 */
	public function useCityQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
	{
		return $this
			->joinCity($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'City', 'CityQuery');
	}

	/**
	 * Filter the query by a related Customer object
	 *
	 * @param     Customer $customer  the related object to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function filterByCustomer($customer, $comparison = null)
	{
		if ($customer instanceof Customer) {
			return $this
				->addUsingAlias(PersonPeer::PERSONID, $customer->getPersonid(), $comparison);
		} elseif ($customer instanceof PropelCollection) {
			return $this
				->useCustomerQuery()
				->filterByPrimaryKeys($customer->getPrimaryKeys())
				->endUse();
		} else {
			throw new PropelException('filterByCustomer() only accepts arguments of type Customer or PropelCollection');
		}
	}

	/**
	 * Adds a JOIN clause to the query using the Customer relation
	 *
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function joinCustomer($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('Customer');

		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}

		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'Customer');
		}

		return $this;
	}

	/**
	 * Use the Customer relation Customer object
	 *
	 * @see       useQuery()
	 *
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    CustomerQuery A secondary query class using the current class as primary query
	 */
	public function useCustomerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		return $this
			->joinCustomer($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'Customer', 'CustomerQuery');
	}

	/**
	 * Filter the query by a related Licence object
	 *
	 * @param     Licence $licence  the related object to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function filterByLicence($licence, $comparison = null)
	{
		if ($licence instanceof Licence) {
			return $this
				->addUsingAlias(PersonPeer::PERSONID, $licence->getPersonid(), $comparison);
		} elseif ($licence instanceof PropelCollection) {
			return $this
				->useLicenceQuery()
				->filterByPrimaryKeys($licence->getPrimaryKeys())
				->endUse();
		} else {
			throw new PropelException('filterByLicence() only accepts arguments of type Licence or PropelCollection');
		}
	}

	/**
	 * Adds a JOIN clause to the query using the Licence relation
	 *
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function joinLicence($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('Licence');

		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}

		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'Licence');
		}

		return $this;
	}

	/**
	 * Use the Licence relation Licence object
	 *
	 * @see       useQuery()
	 *
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    LicenceQuery A secondary query class using the current class as primary query
	 */
	public function useLicenceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		return $this
			->joinLicence($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'Licence', 'LicenceQuery');
	}

	/**
	 * Exclude object from result
	 *
	 * @param     Person $person Object to remove from the list of results
	 *
	 * @return    PersonQuery The current query, for fluid interface
	 */
	public function prune($person = null)
	{
		if ($person) {
			$this->addUsingAlias(PersonPeer::PERSONID, $person->getPersonid(), Criteria::NOT_EQUAL);
		}

		return $this;
	}

} // BasePersonQuery